home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / GMTTime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  1.9 KB  |  74 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        GMTTime.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef    __GMTTIME__
  15. #define    __GMTTIME__
  16.  
  17. #ifndef    __DIRECTOBJECT__
  18. #include "DirectObject.h"
  19. #endif
  20.  
  21. class ostream;
  22. class TAbstractFile;
  23.  
  24. /***********************************|****************************************/
  25.  
  26. typedef unsigned long    Time;        // seconds since 1/1/1904
  27. typedef short            TimeZone;    // minutes offset from GMT
  28.  
  29. class TTimeStamp : public TDirectObject
  30. {
  31. public:
  32.  
  33.             TTimeStamp ();
  34.     virtual    ~TTimeStamp ();
  35.  
  36.             TTimeStamp&                operator = ( const TTimeStamp& );
  37.             Boolean                    operator == ( const TTimeStamp& ) const;
  38.             Boolean                    operator != ( const TTimeStamp& ) const;
  39.  
  40.                                     operator Time () const;
  41.  
  42.             void                    SetToLocalTime ();
  43.             void                    ConvertToZone ( TimeZone );
  44.  
  45.             char*                    CreateString () const;
  46.             unsigned long            GetStringLength () const;
  47.             void                    MakeString ( char* buffer, unsigned long size ) const;
  48.  
  49.     virtual    Boolean                    WriteTo ( TAbstractFile& ) const;
  50.     virtual    Boolean                    ReadFrom ( TAbstractFile& );
  51.  
  52.     virtual    ostream&                operator >> ( ostream& ) const;
  53.  
  54. protected:
  55.  
  56.     static    TimeZone                GetLocalZone ();
  57.     static    Time                    GetLocalTime ();
  58.     static    Time                    GetZoneDifference ( const TimeZone local, const TimeZone reference );
  59.  
  60. private:    Time                    fOriginTime;
  61.             TimeZone                fOriginZone;
  62. };
  63.  
  64. /***********************************|****************************************/
  65.  
  66. extern unsigned long GetCurrentGMTSeconds ();
  67. extern long GetLocalOffsetEastOfGMTInSeconds ();    // negative for values west of GMT
  68. extern unsigned long ConvertGMTSecondsToLocalSeconds ( unsigned long gmtSeconds );
  69. extern unsigned long ConvertLocalSecondsToGMTSeconds ( unsigned long localSeconds );
  70.  
  71. /***********************************|****************************************/
  72.  
  73. #endif    // __GMTTIME__
  74.